package my.jwds.lcp17;

public class Calculate {

    public static void main(String[] args) {

        Calculate obj = new Calculate();
        long start = System.currentTimeMillis();
        System.out.println(obj.calculate("BBBBBBBBBB"));
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    public int calculate(String s) {
        int x = 1,y=0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A'){
                x = compute(x,y);
            }else{
                y = compute(y,x);
            }
        }
        return x+y;
    }
    private int compute(int x,int y){
        return 2*x+y;
    }
    public int calculate1(String s) {
       return (int) Math.pow(2,s.length());
    }
}